//
//  HZMoreView.m
//  Stock_Health
//
//  Created by zeroing on 17/5/24.
//  Copyright © 2017年 MayerF. All rights reserved.
//

#import "HZMoreView.h"
#import "HZMoreButtons.h"

@interface HZMoreView()
@property(nonatomic,strong)UIScrollView  *pScrollView;
@property(nonatomic,strong)UIView *pContentSizeView;
@property(nonatomic,strong)HZMoreButtons *pMoreBtns_HS;
@property(nonatomic,strong)HZMoreButtons *pMoreBtns_GG;
@property(nonatomic,strong)HZMoreButtons *pMoreBtns_JJ;
@property(nonatomic,strong)HZMoreButtons *pMoreBtns_GNQH;
@property(nonatomic,strong)HZMoreButtons *pMoreBtns_QQ;
@end

@implementation HZMoreView
#pragma mark -
#pragma mark 生命周期
- (instancetype)init{
    self = [super init];
    if (self) {
        [self p_commonInit];
        self.backgroundColor = kMYHexToRGB(0xe8e8e8, 1);
    }
    return self;
}

- (void)p_commonInit
{
    _pScrollView = [UIScrollView new];
    _pScrollView.bounces = NO;
    [self addSubview:_pScrollView];
    
    _pContentSizeView = [UIView new];
    _pContentSizeView.backgroundColor = [UIColor clearColor];
    [_pScrollView addSubview:_pContentSizeView];

    _pMoreBtns_HS = [HZMoreButtons new];
    _pMoreBtns_HS.parent = self;
    [_pContentSizeView addSubview:_pMoreBtns_HS];
    
    _pMoreBtns_GG = [HZMoreButtons new];
    _pMoreBtns_GG.parent = self;
//    [_pContentSizeView addSubview:_pMoreBtns_GG];
    
    _pMoreBtns_JJ = [HZMoreButtons new];
    _pMoreBtns_JJ.parent = self;
    [_pContentSizeView addSubview:_pMoreBtns_JJ];
    
    _pMoreBtns_GNQH = [HZMoreButtons new];
    _pMoreBtns_GNQH.parent = self;
//    [_pContentSizeView addSubview:_pMoreBtns_GNQH];
    
    _pMoreBtns_QQ = [HZMoreButtons new];
    _pMoreBtns_QQ.parent = self;
//    [_pContentSizeView addSubview:_pMoreBtns_QQ];
    
    [self p_initConstraints];
    [self p_initData];
}

-(void)p_initConstraints{
    [_pScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self);
        make.left.mas_equalTo(self);
        make.right.mas_equalTo(self);
        make.bottom.mas_equalTo(self);
    }];
    [_pContentSizeView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(_pScrollView);
        make.width.mas_equalTo(_pScrollView);
        make.bottom.mas_equalTo(_pMoreBtns_JJ.mas_bottom);
    }];
    [_pMoreBtns_HS mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_pContentSizeView);
        make.left.mas_equalTo(_pContentSizeView);
        make.right.mas_equalTo(_pContentSizeView);
        make.height.mas_equalTo(kScreenH * (0.076*4+0.086-0.03));
    }];
//    [_pMoreBtns_GG mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.mas_equalTo(_pMoreBtns_HS.mas_bottom);
//        make.left.mas_equalTo(_pContentSizeView);
//        make.right.mas_equalTo(_pContentSizeView);
//        make.height.mas_equalTo(0);
//    }];
    [_pMoreBtns_JJ mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_pMoreBtns_HS.mas_bottom);
        make.left.mas_equalTo(_pScrollView);
        make.right.mas_equalTo(_pScrollView);
        make.height.mas_equalTo(kScreenH * (0.076*2+0.086-0.03));
    }];
//    [_pMoreBtns_GNQH mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.mas_equalTo(_pMoreBtns_JJ.mas_bottom);
//        make.left.mas_equalTo(_pContentSizeView);
//        make.right.mas_equalTo(_pContentSizeView);
//        make.height.mas_equalTo(0);
//    }];
//    [_pMoreBtns_QQ mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.mas_equalTo(_pMoreBtns_GNQH.mas_bottom);
//        make.left.mas_equalTo(_pContentSizeView);
//        make.right.mas_equalTo(_pContentSizeView);
//        make.height.mas_equalTo(0);
//    }];
}

-(void)p_initData{
    NSArray *dataArray_Buttons = [NSArray arrayWithObjects:/*@"BTexA股",*/@"上证A股",@"深证A股",/*@"主板A股",*/@"中小企业板",@"创业板",/*@"BTexB股",*/@"上证B股",@"深证B股",/*@"BTexAB股",@"三板市场",*/@"风险警示板",@"B股转H股",@"上证50",@"上证180",/*@"深证成指",*/@"深证100",@"BTex300",nil];
    [_pMoreBtns_HS setData:@"BTex" withButtons:dataArray_Buttons];
    
    dataArray_Buttons = [NSArray arrayWithObjects:@"港股okex",@"港股主板",@"港股创业",nil];
//    [_pMoreBtns_GG setData:@"港股" withButtons:dataArray_Buttons];
    
    dataArray_Buttons = [NSArray arrayWithObjects:@"上证基金",@"深证基金",@"开放式基金",@"封闭式基金",@"LOF",@"ETF",nil];
    [_pMoreBtns_JJ setData:@"基金" withButtons:dataArray_Buttons];
    
    dataArray_Buttons = [NSArray arrayWithObjects:@"中金所",@"上期所",@"郑商所",@"大商所",nil];
//    [_pMoreBtns_GNQH setData:@"国内期货" withButtons:dataArray_Buttons];
    
    dataArray_Buttons = [NSArray arrayWithObjects:@"全球okex",nil];
//    [_pMoreBtns_QQ setData:@"全球" withButtons:dataArray_Buttons];
}

#pragma mark -
- (void)upToParentWithObjc:(id)objc withType:(NSInteger)type withParamter:(id)paramter{
    [self.parent upToParentWithObjc:objc withType:type withParamter:paramter];
}

- (void)downToChildWithObjc:(id)objc withType:(NSInteger)type withParamter:(id)paramter{
    switch (type) {
        case kHZ_updateNewData_Action:
        {
            if ([paramter isKindOfClass:[NSArray class]]) {
                //                [self p_updateNewData:paramter];
            }
        }
            break;
            
        default:
            break;
    }
}
@end
